﻿using System;

namespace LiveNet.Authentication
{
    public sealed class DefaultAuthenticationDetails : LiveNetAuthenticationDetails
    {
        private readonly string m_UserId;
        private readonly string m_Token;
        private readonly AuthenticationToken m_TokenType;
        private readonly string m_lid;
        private readonly string m_dat;

        public DefaultAuthenticationDetails(string Id, string token, AuthenticationToken tokenType)
        {
            if (string.IsNullOrEmpty(Id))
            {
                throw new ArgumentNullException("ID");
            }

            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentNullException("token");
            }

            if (!(tokenType == AuthenticationToken.DomainAuthenticationToken ||
                tokenType == AuthenticationToken.RelyingPartySuite ||
                tokenType == AuthenticationToken.DelegatedToken))
            {
                throw new ArgumentException(LiveNetResources.InvalidTokenTypeException, "tokenType");
            }

            if (tokenType == AuthenticationToken.DelegatedToken)
            {
                m_lid = Id;
            }
            else
            {
                m_UserId = Id;
            }
            m_Token = token;
            m_TokenType = tokenType;
        }

        public string Token
        {
            get { return m_Token; }
        }

        public string UserId
        {
            get { return m_UserId; }
        }

        public AuthenticationToken TokenType
        {
            get { return m_TokenType; }
        }

        public string LocationID
        {
            get { return m_lid; }
        }

        public string DAT
        {
            get { return m_dat; }
        }
    }
}
